﻿//-----------------------------------------------------------------------------
// <copyright file="FrameworkElementWrapper.cs" company="William E. Kempf">
//     Copyright (c) William E. Kempf.
// </copyright>
//-----------------------------------------------------------------------------

namespace Onyx.Windows
{
    using System;
    using System.Windows;
    using System.Windows.Controls;
    using System.Windows.Data;
    using System.Windows.Input;
    using System.Windows.Markup;
    using System.Windows.Media.Animation;

    internal class FrameworkElementWrapper : IFrameworkObject
    {
        private readonly FrameworkElement element;

        public FrameworkElementWrapper(FrameworkElement element)
        {
            this.element = element;
        }

#if WPF
        public void BeginStoryboard(Storyboard storyboard)
        {
            this.element.BeginStoryboard(storyboard);
        }

        public void BeginStoryboard(Storyboard storyboard, HandoffBehavior handoffBehavior)
        {
            this.element.BeginStoryboard(storyboard, handoffBehavior);
        }

        public void BeginStoryboard(Storyboard storyboard, HandoffBehavior handoffBehavior, bool isControllable)
        {
            this.element.BeginStoryboard(storyboard, handoffBehavior, isControllable);
        }

        public void BringIntoView()
        {
            this.element.BringIntoView();
        }

        public object FindResource(object resourceKey)
        {
            return this.element.FindResource(resourceKey);
        }

        public BindingExpression GetBindingExpression(DependencyProperty dp)
        {
            return this.element.GetBindingExpression(dp);
        }

        public bool MoveFocus(TraversalRequest request)
        {
            return this.element.MoveFocus(request);
        }

        public DependencyObject PredictFocus(FocusNavigationDirection direction)
        {
            return this.element.PredictFocus(direction);
        }

        public void RegisterName(string name, object scopedElement)
        {
            this.element.RegisterName(name, scopedElement);
        }

        public BindingExpression SetBinding(DependencyProperty dp, string path)
        {
            return this.element.SetBinding(dp, path);
        }

        public BindingExpressionBase SetBinding(DependencyProperty dp, BindingBase binding)
        {
            return this.element.SetBinding(dp, binding);
        }

        public void SetResourceReference(DependencyProperty dp, object name)
        {
            this.element.SetResourceReference(dp, name);
        }

        public bool ShouldSerializeResources()
        {
            return this.element.ShouldSerializeResources();
        }

        public bool ShouldSerializeStyle()
        {
            return this.element.ShouldSerializeStyle();
        }

        public object TryFindResource(object resourceKey)
        {
            return this.element.TryFindResource(resourceKey);
        }

        public void UnregisterName(string name)
        {
            this.element.UnregisterName(name);
        }

        public ContextMenu ContextMenu
        {
            get
            {
                return this.element.ContextMenu;
            }
            set
            {
                this.element.ContextMenu = value;
            }
        }

        public Style FocusVisualStyle
        {
            get
            {
                return this.element.FocusVisualStyle;
            }
            set
            {
                this.element.FocusVisualStyle = value;
            }
        }

        public bool ForceCursor
        {
            get
            {
                return this.element.ForceCursor;
            }
            set
            {
                this.element.ForceCursor = value;
            }
        }

        public InputScope InputScope
        {
            get
            {
                return this.element.InputScope;
            }
            set
            {
                this.element.InputScope = value;
            }
        }

        public bool IsInitialized
        {
            get { return this.element.IsInitialized; }
        }

        public bool IsLoaded
        {
            get { return this.element.IsLoaded; }
        }

        public bool OverridesDefaultStyle
        {
            get
            {
                return this.element.OverridesDefaultStyle;
            }
            set
            {
                this.element.OverridesDefaultStyle = value;
            }
        }

        public DependencyObject TemplatedParent
        {
            get { return this.element.TemplatedParent; }
        }

        public object ToolTip
        {
            get
            {
                return this.element.ToolTip;
            }
            set
            {
                this.element.ToolTip = value;
            }
        }

        public event ContextMenuEventHandler ContextMenuClosing
        {
            add { this.element.ContextMenuClosing += value; }
            remove { this.element.ContextMenuClosing -= value; }
        }

        public event ContextMenuEventHandler ContextMenuOpening
        {
            add { this.element.ContextMenuOpening += value; }
            remove { this.element.ContextMenuOpening -= value; }
        }

        public event DependencyPropertyChangedEventHandler DataContextChanged
        {
            add { this.element.DataContextChanged += value; }
            remove { this.element.DataContextChanged -= value; }
        }

        public event EventHandler Initialized
        {
            add { this.element.Initialized += value; }
            remove { this.element.Initialized -= value; }
        }

        public event EventHandler<DataTransferEventArgs> SourceUpdated
        {
            add { this.element.SourceUpdated += value; }
            remove { this.element.SourceUpdated -= value; }
        }

        public event EventHandler<DataTransferEventArgs> TargetUpdated
        {
            add { this.element.TargetUpdated += value; }
            remove { this.element.TargetUpdated -= value; }
        }

        public event ToolTipEventHandler ToolTipClosing
        {
            add { this.element.ToolTipClosing += value; }
            remove { this.element.ToolTipClosing -= value; }
        }

        public event ToolTipEventHandler ToolTipOpening
        {
            add { this.element.ToolTipOpening += value; }
            remove { this.element.ToolTipOpening -= value; }
        }

        public event RoutedEventHandler Unloaded
        {
            add { this.element.Unloaded += value; }
            remove { this.element.Unloaded -= value; }
        }

        public void AddHandler(RoutedEvent routedEvent, Delegate handler)
        {
            this.element.AddHandler(routedEvent, handler);
        }

        public bool CaptureStylus()
        {
            return this.element.CaptureStylus();
        }

        public void RaiseEvent(RoutedEventArgs e)
        {
            this.element.RaiseEvent(e);
        }

        public void ReleaseStylusCapture()
        {
            this.element.ReleaseStylusCapture();
        }

        public void RemoveHandler(RoutedEvent routedEvent, Delegate handler)
        {
            this.element.RemoveHandler(routedEvent, handler);
        }

        public bool Focusable
        {
            get
            {
                return this.element.Focusable;
            }
            set
            {
                this.element.Focusable = value;
            }
        }

        public bool IsEnabled
        {
            get { return this.element.IsEnabled; }
        }

        public bool IsKeyboardFocused
        {
            get { return this.element.IsKeyboardFocused; }
        }

        public bool IsKeyboardFocusWithin
        {
            get { return this.element.IsKeyboardFocusWithin; }
        }

        public bool IsMouseCaptured
        {
            get { return this.element.IsMouseCaptured; }
        }

        public bool IsMouseDirectlyOver
        {
            get { return this.element.IsMouseDirectlyOver; }
        }

        public bool IsMouseOver
        {
            get { return this.element.IsMouseOver; }
        }

        public bool IsStylusCaptured
        {
            get { return this.element.IsStylusCaptured; }
        }

        public bool IsStylusDirectlyOver
        {
            get { return this.element.IsStylusDirectlyOver; }
        }

        public bool IsStylusOver
        {
            get { return this.element.IsStylusOver; }
        }

        public event KeyboardFocusChangedEventHandler GotKeyboardFocus
        {
            add { this.element.GotKeyboardFocus += value; }
            remove { this.element.GotKeyboardFocus -= value; }
        }

        public event MouseEventHandler GotMouseCapture
        {
            add { this.element.GotMouseCapture += value; }
            remove { this.element.GotMouseCapture -= value; }
        }

        public event StylusEventHandler GotStylusCapture
        {
            add { this.element.GotStylusCapture += value; }
            remove { this.element.GotStylusCapture -= value; }
        }

        public event KeyboardFocusChangedEventHandler LostKeyboardFocus
        {
            add { this.element.LostKeyboardFocus += value; }
            remove { this.element.LostKeyboardFocus -= value; }
        }

        public event StylusEventHandler LostStylusCapture
        {
            add { this.element.LostStylusCapture += value; }
            remove { this.element.LostStylusCapture -= value; }
        }

        public event MouseButtonEventHandler MouseRightButtonDown
        {
            add { this.element.MouseRightButtonDown += value; }
            remove { this.element.MouseRightButtonDown -= value; }
        }

        public event MouseButtonEventHandler MouseRightButtonUp
        {
            add { this.element.MouseRightButtonUp += value; }
            remove { this.element.MouseRightButtonUp -= value; }
        }

        public event MouseWheelEventHandler MouseWheel
        {
            add { this.element.MouseWheel += value; }
            remove { this.element.MouseWheel -= value; }
        }

        public event KeyboardFocusChangedEventHandler PreviewGotKeyboardFocus
        {
            add { this.element.PreviewGotKeyboardFocus += value; }
            remove { this.element.PreviewGotKeyboardFocus -= value; }
        }

        public event KeyEventHandler PreviewKeyDown
        {
            add { this.element.PreviewKeyDown += value; }
            remove { this.element.PreviewKeyDown -= value; }
        }

        public event KeyEventHandler PreviewKeyUp
        {
            add { this.element.PreviewKeyUp += value; }
            remove { this.element.PreviewKeyUp -= value; }
        }

        public event KeyboardFocusChangedEventHandler PreviewLostKeyboardFocus
        {
            add { this.element.PreviewLostKeyboardFocus += value; }
            remove { this.element.PreviewLostKeyboardFocus -= value; }
        }

        public event MouseButtonEventHandler PreviewMouseLeftButtonDown
        {
            add { this.element.PreviewMouseLeftButtonDown += value; }
            remove { this.element.PreviewMouseLeftButtonDown -= value; }
        }

        public event MouseButtonEventHandler PreviewMouseLeftButtonUp
        {
            add { this.element.PreviewMouseLeftButtonUp += value; }
            remove { this.element.PreviewMouseLeftButtonUp -= value; }
        }

        public event MouseEventHandler PreviewMouseMove
        {
            add { this.element.PreviewMouseMove += value; }
            remove { this.element.PreviewMouseMove -= value; }
        }

        public event MouseButtonEventHandler PreviewMouseRightButtonDown
        {
            add { this.element.PreviewMouseRightButtonDown += value; }
            remove { this.element.PreviewMouseRightButtonDown -= value; }
        }

        public event MouseButtonEventHandler PreviewMouseRightButtonUp
        {
            add { this.element.PreviewMouseRightButtonUp += value; }
            remove { this.element.PreviewMouseRightButtonUp -= value; }
        }

        public event MouseWheelEventHandler PreviewMouseWheel
        {
            add { this.element.PreviewMouseWheel += value; }
            remove { this.element.PreviewMouseWheel -= value; }
        }

        public event StylusButtonEventHandler PreviewStylusButtonDown
        {
            add { this.element.PreviewStylusButtonDown += value; }
            remove { this.element.PreviewStylusButtonDown -= value; }
        }

        public event StylusButtonEventHandler PreviewStylusButtonUp
        {
            add { this.element.PreviewStylusButtonUp += value; }
            remove { this.element.PreviewStylusButtonUp -= value; }
        }

        public event StylusDownEventHandler PreviewStylusDown
        {
            add { this.element.PreviewStylusDown += value; }
            remove { this.element.PreviewStylusDown -= value; }
        }

        public event StylusEventHandler PreviewStylusInAirMove
        {
            add { this.element.PreviewStylusInAirMove += value; }
            remove { this.element.PreviewStylusInAirMove -= value; }
        }

        public event StylusEventHandler PreviewStylusInRange
        {
            add { this.element.PreviewStylusInRange += value; }
            remove { this.element.PreviewStylusInRange -= value; }
        }

        public event StylusEventHandler PreviewStylusMove
        {
            add { this.element.PreviewStylusMove += value; }
            remove { this.element.PreviewStylusMove -= value; }
        }

        public event StylusEventHandler PreviewStylusOutOfRange
        {
            add { this.element.PreviewStylusOutOfRange += value; }
            remove { this.element.PreviewStylusOutOfRange -= value; }
        }

        public event StylusSystemGestureEventHandler PreviewStylusSystemGesture
        {
            add { this.element.PreviewStylusSystemGesture += value; }
            remove { this.element.PreviewStylusSystemGesture -= value; }
        }

        public event StylusEventHandler PreviewStylusUp
        {
            add { this.element.PreviewStylusUp += value; }
            remove { this.element.PreviewStylusUp -= value; }
        }

        public event TextCompositionEventHandler PreviewTextInput
        {
            add { this.element.PreviewTextInput += value; }
            remove { this.element.PreviewTextInput -= value; }
        }

        public event StylusButtonEventHandler StylusButtonDown
        {
            add { this.element.StylusButtonDown += value; }
            remove { this.element.StylusButtonDown -= value; }
        }

        public event StylusButtonEventHandler StylusButtonUp
        {
            add { this.element.StylusButtonUp += value; }
            remove { this.element.StylusButtonUp -= value; }
        }

        public event StylusDownEventHandler StylusDown
        {
            add { this.element.StylusDown += value; }
            remove { this.element.StylusDown -= value; }
        }

        public event StylusEventHandler StylusEnter
        {
            add { this.element.StylusEnter += value; }
            remove { this.element.StylusEnter -= value; }
        }

        public event StylusEventHandler StylusInAirMove
        {
            add { this.element.StylusInAirMove += value; }
            remove { this.element.StylusInAirMove -= value; }
        }

        public event StylusEventHandler StylusInRange
        {
            add { this.element.StylusInRange += value; }
            remove { this.element.StylusInRange -= value; }
        }

        public event StylusEventHandler StylusLeave
        {
            add { this.element.StylusLeave += value; }
            remove { this.element.StylusLeave -= value; }
        }

        public event StylusEventHandler StylusMove
        {
            add { this.element.StylusMove += value; }
            remove { this.element.StylusMove -= value; }
        }

        public event StylusEventHandler StylusOutOfRange
        {
            add { this.element.StylusOutOfRange += value; }
            remove { this.element.StylusOutOfRange -= value; }
        }

        public event StylusSystemGestureEventHandler StylusSystemGesture
        {
            add { this.element.StylusSystemGesture += value; }
            remove { this.element.StylusSystemGesture -= value; }
        }

        public event StylusEventHandler StylusUp
        {
            add { this.element.StylusUp += value; }
            remove { this.element.StylusUp -= value; }
        }

        public event TextCompositionEventHandler TextInput
        {
            add { this.element.TextInput += value; }
            remove { this.element.TextInput -= value; }
        }

        public void BeginInit()
        {
            this.element.BeginInit();
        }

        public void EndInit()
        {
            this.element.EndInit();
        }

        public bool Focus()
        {
            return this.element.Focus();
        }
#endif

#if SILVERLIGHT
        public BindingExpressionBase SetBinding(DependencyProperty dp, Binding binding)
        {
            return this.element.SetBinding(dp, binding);
        }
#endif

        public object FindName(string name)
        {
            return this.element.FindName(name);
        }

        public Cursor Cursor
        {
            get
            {
                return this.element.Cursor;
            }
            set
            {
                this.element.Cursor = value;
            }
        }

        public object DataContext
        {
            get
            {
                return this.element.DataContext;
            }
            set
            {
                this.element.DataContext = value;
            }
        }

        public XmlLanguage Language
        {
            get
            {
                return this.element.Language;
            }
            set
            {
                this.element.Language = value;
            }
        }

        public DependencyObject Parent
        {
            get { return this.element.Parent; }
        }

        public ResourceDictionary Resources
        {
            get
            {
                return this.element.Resources;
            }

#if WPF
            set
            {
                this.element.Resources = value;
            }
#endif
        }

        public Style Style
        {
            get
            {
                return this.element.Style;
            }
            set
            {
                this.element.Style = value;
            }
        }

        public object Tag
        {
            get
            {
                return this.element.Tag;
            }
            set
            {
                this.element.Tag = value;
            }
        }

        public event RoutedEventHandler Loaded
        {
            add { this.element.Loaded += value; }
            remove { this.element.Loaded -= value; }
        }

        public string Name
        {
            get
            {
                return this.element.Name;
            }
            set
            {
                this.element.Name = value;
            }
        }

        public bool CaptureMouse()
        {
            return this.element.CaptureMouse();
        }

        public event KeyEventHandler KeyDown
        {
            add { this.element.KeyDown += value; }
            remove { this.element.KeyDown -= value; }
        }

        public event KeyEventHandler KeyUp
        {
            add { this.element.KeyUp += value; }
            remove { this.element.KeyUp -= value; }
        }

        public event MouseEventHandler LostMouseCapture
        {
            add { this.element.LostMouseCapture += value; }
            remove { this.element.LostMouseCapture -= value; }
        }

        public event MouseEventHandler MouseEnter
        {
            add { this.element.MouseEnter += value; }
            remove { this.element.MouseEnter -= value; }
        }

        public event MouseEventHandler MouseLeave
        {
            add { this.element.MouseLeave += value; }
            remove { this.element.MouseLeave -= value; }
        }

        public event MouseButtonEventHandler MouseLeftButtonDown
        {
            add { this.element.MouseLeftButtonDown += value; }
            remove { this.element.MouseLeftButtonDown -= value; }
        }

        public event MouseButtonEventHandler MouseLeftButtonUp
        {
            add { this.element.MouseLeftButtonUp += value; }
            remove { this.element.MouseLeftButtonUp -= value; }
        }

        public event MouseEventHandler MouseMove
        {
            add { this.element.MouseMove += value; }
            remove { this.element.MouseMove -= value; }
        }

        public void ReleaseMouseCapture()
        {
            this.element.ReleaseMouseCapture();
        }
    }
}
